#include <iostream>
#include <string>
#include <algorithm>

bool check(const std::string& a) {
    if (std::count(a.begin(), a.end(), '(') == std::count(a.begin(), a.end(), ')')) {
        if (std::count(a.begin(), a.end(), '{') == std::count(a.begin(), a.end(), '}')) {
            if (std::count(a.begin(), a.end(), '[') == std::count(a.begin(), a.end(), ']')) {
                if (std::count(a.begin(), a.end(), '<') == std::count(a.begin(), a.end(), '>')) {
                    return true;
                }
            }
        }
    }
    return false;
}

int main() {
    std::string s;
    std::cout << "Введите последовательность скобок ";
    std::cin >> s;
    if (check(s)) {
        std::string d;
        std::sort(s.begin(), s.end());
        auto last = std::unique(s.begin(), s.end());
        s.erase(last, s.end());
        d = s;
        
        size_t n1 = d.find('{');
        size_t n2 = d.find('}');
        if (n1 != std::string::npos && n2 != std::string::npos && n1 < n2) {
            std::cout << "true\n";
        } else {
            std::cout << "false\n";
        }
        
        size_t n3 = d.find('(');
        size_t n4 = d.find(')');
        if (n3 != std::string::npos && n4 != std::string::npos && n3 < n4) {
            std::cout << "true\n";
        } else {
            std::cout << "false\n";
        }
        
        size_t n5 = d.find('[');
        size_t n6 = d.find(']');
        if (n5 != std::string::npos && n6 != std::string::npos && n5 < n6) {
            std::cout << "true\n";
        } else {
            std::cout << "false\n";
        }
        
        n5 = d.find('<');
        n6 = d.find('>');
        if (n5 != std::string::npos && n6 != std::string::npos && n5 < n6) {
            std::cout << "true\n";
        } else {
            std::cout << "false\n";
        }
    } else {
        std::cout << "false\n";
    }
    return 0;
}
